package cn.edu.scau.cmi.luotiansheng.adapter;


import java.util.ArrayList;
import java.util.List;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class ClassAdapterController {
	
	private ClassAdapter classAdapter=new ClassAdapter();
	

    @FXML
    private Button btn_add;

    @FXML
    private TextField tv_name;

    @FXML
    private TextArea ta_show;

    @FXML
    private TextField tv_Sno;

    @FXML
    void addStudent(ActionEvent event) {
    	ta_show.setText("");
    	
    	Integer sno=Integer.valueOf(tv_Sno.getText());
    	String name=tv_name.getText();
    	Student student=new Student();
    	student.setSno(sno);
    	student.setName(name);
    	
    	classAdapter.getStudentList().add(student);
    	
    	List<Student> studentList=classAdapter.sortStudent();
    	
    	for(int i=0;i<studentList.size();i++) {
    		ta_show.appendText(studentList.get(i)+"\n");	
    	}
    	
    }

}
